import os

path_list = [
    '/data/ICE/DataSetCollection/record_b2/labeled/collection',
     '/data/ICE/DataSetCollection/indemind/collection/dataset',
     '/data/ICE/DataSetCollection/902_bug_20210826/collection',
     '/data/ICE/DataSetCollection/i18R_902_20210705/record_1/dataset/dataset_v1',
     '/data/ICE/DataSetCollection/i18R_902_20210705/record_2/dataset/dataset_v1',
     '/data/ICE/DataSetCollection/i18R_902_20210705/record_3/dataset/dataset_v1',
     '/data/ICE/DataSetCollection/batch2_batch3_tiny',
     '/data/ICE/DataSetCollection/batch4_06_04_extract',
     '/data/ICE/DataSetCollection/batch5_06_04_extract',
     '/data/ICE/DataSetCollection/batch6_20210610_extract/dataset',
     '/data/ICE/DataSetCollection/batch7_06_21_valid_extract/dataset',
     '/data/ICE/DataSetCollection/escalator_cover/collection',
     '/data/ICE/DataSetCollection/i18Rperson_model_dummy/dataset_v1',
    # '/data/ICE/DataSetCollection/openData/all_usc_data',
    # '/data/ICE/DataSetCollection/openData/all_iccv_data',
    '/data/ICE/coco/indemind_train2017/VOC2007'
    ]
test_file = os.path.join('/workspace/nanodet/config', 'test.txt')
train_file = os.path.join('/workspace/nanodet/config', 'train.txt')
f_test = open(test_file, 'w')
f_train = open(train_file, 'w')
for path in path_list:
    files = os.listdir(path)
    print('\033[34m', path)

    for file in files:
        if file == 'train.txt':
            print('\033[35m', file)
            text_train_path = os.path.join(path, file)
            # with open(text_train_path, 'r') as file_train:
            #     lines = file_train.readlines()
            #     for line in lines:
            #         text = line.strip()
            #         f_test.write(text + '\n')
            for line in open(text_train_path, 'r'):
                f_train.writelines(line)
        if file == 'test.txt':
            print('\033[36m', file)
            text_test_path = os.path.join(path, file)
            for line in open(text_test_path, 'r'):
                f_test.writelines(line)
f_train.close()
f_test.close()
